package pl.edu.agh.gt.ga.greedy;

import pl.edu.agh.gt.ga.CrossbreedOperator;
import pl.edu.agh.gt.ga.Genotype;
import pl.edu.agh.gt.ga.Parameters;
import pl.edu.agh.gt.util.BetterRandom;

public class CrossbreedImlpl implements CrossbreedOperator {

	@Override
	public Genotype crossbreed(Genotype g1, Genotype g2, Parameters params) {
		
		Genotype newGenes = InitializerImpl.createGenotype();
		
		for(String name : g1.getGenes().keySet()) {
			
			if( BetterRandom.nextBoolean("xbg") ) {
				newGenes.setGene(name, g1.getGene(name));
			} else {
				newGenes.setGene(name, g2.getGene(name));
			}				
		}
		
		return newGenes;
	}

}
